home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 412_01 / include / bisearch.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-01  |  1.4 KB  |  49 lines

  1. /*                      BISEARCH_
  2.  
  3.    
  4.     The base class BISEARCH_ defines a skeleton search class from
  5.     which more the actual search classes such as BIDEPTH_GRAPH_
  6.     are derived, cf class SEARCH_! Class BISEARCH_ differs from class
  7.     SEARCH_ in that it implements a bidirectional search instead of 
  8.     a uni-directional search like class SEARCH_. It uses two sets of
  9.     lists to search both forward from the start (s_open, s_closed) and
  10.     backward to the goal (t_open, t_closed) simultaneously.
  11.  
  12. */ 
  13.   
  14. #ifndef _bisearch_H_
  15. #define _bisearch_H_
  16.  
  17. #include <stdio.h>
  18. #include "object.h"
  19. #include "nodes.h"
  20. #include "list.h"
  21.  
  22. class BISEARCH_
  23. {
  24.     public:
  25.         BISEARCH_(NODE_ *start, NODE_ *goal, int numop);
  26.     virtual ~BISEARCH_();
  27.  
  28.         void generate();
  29.         NODE_ *bisolve();
  30.                // determines in which direction the search continues    
  31.         NODE_ *solve(SORTEDLIST_ *, SORTEDLIST_ *, SORTEDLIST_ *);
  32.                // expand a node and pass it to open 
  33.  
  34.         void print_sol(NODE_ *) const;        // print backwards
  35.     void print_sol_2(NODE_ *) const;      // print forwards
  36.  
  37.         virtual int add(SORTEDLIST_ *, SORTEDLIST_ *, NODE_ *) = 0;
  38.     private:
  39.         int num_op;
  40.     protected:     // protected since several classes need access through add() 
  41.         SORTEDLIST_ s_open,
  42.                     s_closed,
  43.                     t_open,
  44.             t_closed;
  45. };
  46.  
  47. #endif
  48.  
  49.